Skip to content

light-client-wasm: support using JS object as configuration#230

Merged
quake merged 1 commit intodevelopfrom
support-json-as-configuration
Jul 14, 2025
Merged

light-client-wasm: support using JS object as configuration#230
quake merged 1 commit intodevelopfrom
support-json-as-configuration

Conversation

@Officeyutong
Copy link
Collaborator

Closes #220

This PR supports using JS object as network config when starting a light client wasm instance, for example:

const networkConfig = {
    "chain": "testnet",
    "store": {
        "path": "data/store"
    },
    "network": {
        "path": "data/network",
        "listen_addresses": [
            "/ip4/0.0.0.0/tcp/8110"
        ],
        "bootnodes": [
            "/dns4/dagon.ckb.guide/tcp/443/wss/p2p/QmX5D6aJiAQ5Fxn4BfVqSn6zrgyuQM1oXVC9yvmzLuHXnx",
            "/dns4/javelin.ckb.guide/tcp/443/wss/p2p/QmPcJY2gZLUm66szYA9QaG1P3rzwseWCMgbj6AyNCyW4G2",
            "/dns4/diadem.ckb.guide/tcp/443/wss/p2p/QmQMjFrNGaphzfHin3mbYybbJcFMDUihKAcknquYvm9J3W",
            "/dns4/bloodstone.ckb.guide/tcp/443/wss/p2p/QmQoTR39rBkpZVgLApDGDoFnJ2YDBS9hYeiib1Z6aoAdEf",
            "/dns4/crown.ckb.guide/tcp/443/wss/p2p/QmTt6HeNakL8Fpmevrhdna7J4NzEMf9pLchf1CXtmtSrwb",
            "/dns4/mekansm.ckb.guide/tcp/443/wss/p2p/QmT6DFfm18wtbJz3y4aPNn3ac86N4d4p4xtfQRRPf73frC",
            "/dns4/circlet.ckb.guide/tcp/443/wss/p2p/Qmd41MaByDprkC5gP1XBKgamZ9DTLNk37zbPgwtiWCzRV6",
            "/dns4/vanguard.ckb.guide/tcp/443/wss/p2p/QmWVuW5KquiWDSqgMJRFW1xRtVqkYJrWz6S9NNk6fFn3wh",
            "/dns4/chainmail.ckb.guide/tcp/443/wss/p2p/QmfUTZxsse7rFJTJfoUv8bbStoDLETxst5nJEpJozNuAnH",
            "/dns4/gleipnir.ckb.guide/tcp/443/wss/p2p/QmSPkAyXqsWpRiS7HpHLTProVdhQWLKFHCXbRjaLpJj7ZL",
            "/dns4/parasma.ckb.guide/tcp/443/wss/p2p/QmSJTsMsMGBjzv1oBNwQU36VhQRxc2WQpFoRu1ZifYKrjZ",
            "/dns4/bottle.ckb.guide/tcp/443/wss/p2p/QmWcEhsMNRcfJit62EbKgzpgtAJZX1G3Ur4shXjcvLsYDb"
        ],
        "max_peers": 125,
        "max_outbound_peers": 2,
        "ping_interval_secs": 120,
        "ping_timeout_secs": 1200,
        "connect_outbound_interval_secs": 15,
        "upnp": false,
        "discovery_local_address": false,
        "bootnode_mode": false
    },
    "rpc": {
        "listen_address": "127.0.0.1:9000"
    }
}
await client.start({ type: "TestNet", config: networkConfig }, secretKey, enableDebug ? "debug" : "info", "ws", true);              

As described in function comments, the last argument of LightClient.start is used to indicate whether the network config is in JS object or TOML string.

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 71.80%. Comparing base (cc8f4ab) to head (b50a5ae).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop     #230   +/-   ##
========================================
  Coverage    71.80%   71.80%           
========================================
  Files           27       27           
  Lines         6942     6942           
========================================
  Hits          4985     4985           
  Misses        1957     1957           
Flag Coverage Δ
unittests 71.80% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Officeyutong Officeyutong marked this pull request as ready for review July 4, 2025 11:59
@Officeyutong Officeyutong requested a review from quake July 7, 2025 10:55
@quake quake merged commit d5dd7c1 into develop Jul 14, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support using JSON as configuration

3 participants